<template>
    <div id="login">
        <el-container>
            <el-header>后台管理系统</el-header>
            <el-main>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="用户名" prop="name">
                    <el-input v-model="ruleForm.name"></el-input>
                </el-form-item>
                <el-form-item label="密码" prop="password">
                    <el-input type="password" v-model="ruleForm.password"></el-input>
                </el-form-item>
                
                    <el-button type="primary">立即创建</el-button>
                    <el-button @click="clearAllFormData()">重置</el-button>
                
            </el-form>
            </el-main>
            <el-footer></el-footer>
        </el-container>
        
    </div>
</template>
<script>
export default {
    name:'Login',
    data(){
        return{
            ruleForm:{
                name:'',
                password:''
            },
            rules:{
                name: [
                    { required: true, message: '请输入用户名', trigger: 'blur' },
                    { min: 3, max: 9, message: '长度在 3 到 9 个字符', trigger: 'blur' }
                ],
                password:[
                    { required: true, message: '请输入密码', trigger: 'blur' },
                    { min: 6, max: 16, message: '长度在 6 到 16 个字符', trigger: 'blur' }
                ]
            },
            methods:{
                login(formName) {
                this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('submit!');
                } else {
                    console.log('error submit!!');
                return false;
                }
                });
                },
                clearAllFormData(){   
                    this.$refs['refFormData'].resetFields()  // 这里可以换做移除样式的方法clearValidate
                    this.formData = copyProps(this.formData)  
                }
            }
            
        }
    }
}
</script>
<style>
    *{
      padding: 0;
      margin:0
    }
    .el-container{
        background-color: #B3C0D1;
        margin-top: 10%;
    }
    .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
    .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  .el-form{
      width: 50%;
      margin: 0 auto;
  }
</style>